var config = require('../../config');
var whost = config.whost;
// var whost = config.whost.replace('api', 'boss');
var request = require('../../support').request2;

/**
 * 获取社区公告详情
 * @return {promise}
 */
exports.getNotice = function (context, noticeId) {
  return request(context, {
    url: whost + '/hk-api/api/json/group/getProjectNoticeDetail',
    data: {
      noticeId: noticeId
    }
  }).then(function (data) {
    return {
      notice: data.entity
    };
  });
};

/**
 * 创建收货人地址
 * @return promise
 */
exports.page4HK = function (context, address) {
  return request(context, {
    url: whost + '/crbg/delivery/page4HK',
    method: 'get',
    data: address
  });
};

/**
 * 抢单
 * @return promise
 */
exports.grabExpress = function (context, address) {
  return request(context, {
    url: whost + '/crbg/delivery/grab',
    method: 'post',
    data: address
  });
};

/**
 * 抢单
 * @return promise
 */
exports.cancel4HK = function (context, address) {
  return request(context, {
    url: whost + '/crbg/delivery/cancel4HK',
    method: 'post',
    data: address
  });
};

/**
 * 派送单列表详情
 * @return promise
 */
exports.expressDetail = function (context,params) {
  return request(context, {
    url: whost + '/crbg/delivery/detail',
    method: 'get',
    data:params
  });
};

/**
 * 快递详情
 * @return promise
 */
exports.deliveryDetails = function (context, params) {
  return request(context, {
    url: whost + '/crbg/courier/detail',
    method: 'get',
    data: params
  });
};

/**
 *  派送单状态变更跟踪
 * @return promise
 */
exports.getStatusChangeChain4App = function (context, params) {
  return request(context, {
    url: whost + '/crbg/delivery/getStatusChangeChain4App',
    method: 'get',
    data: params
  });
};

/**
 *  取消配送
 * @return promise
 */
exports.cancel4HK = function (context, params) {
  return request(context, {
    url: whost + '/crbg/delivery/cancel4HK',
    method: 'get',
    data: params
  });
};

/**
 *  扫码领取
 * @return promise
 */
exports.receive = function (context, params) {
  return request(context, {
    url: whost + '/crbg/delivery/receive',
    method: 'get',
    data: params
  });
};

/**
 *  生成二维码
 * @return promise
 */
exports.createQRCode = function (context, params) {
  return request(context, {
    url: whost + '/crbg/delivery/createQRCode',
    method: 'get',
    data: params
  },true);
};

/**
 *  扫码领取
 * @return promise
 */
exports.receive = function (context, params) {
  return request(context, {
    url: whost + '/crbg/delivery/receive',
    method: 'get',
    data: params
  });
};

/**
 *  扫码归还
 * @return promise
 */
exports.giveBack = function (context, params) {
  return request(context, {
    url: whost + '/crbg/delivery/giveBack',
    method: 'get',
    data: params
  });
};


















